<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
include('core/Lib/Util/CommonUtil.class.php');
include('core/Lib/Util/Constant.class.php');

// Define a destination

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
	
	
	
	// Validate the file type
	$fileTypes = $_POST['fileTypeExts']; // File extensions
	$fileParts = pathinfo($_FILES['Filedata']['name']);
	
	if (!empty($fileTypes) && !CommonUtil::contain($fileTypes, $fileParts['extension'])) {
		echo CommonUtil::ajaxReturn(Status::$ERROR, "上传的文件类型不允许，操作失败!");
		exit();
	}
	
	$uploadReturnArr = CommonUtil::upload("Filedata",null, UploadFilePath::$TEMP);
	if($uploadReturnArr["result"] == false){
		echo CommonUtil::ajaxReturn(Status::$ERROR, $uploadReturnArr["msg"]);
		exit();
	}
	
	//操作成功信息返回
	echo CommonUtil::ajaxReturn(1, $uploadReturnArr["msg"]);
	
}
?>